<?php
namespace Idiom\Controller;
use  Common\Controller\IdiomController;
class TestController extends IdiomController {


    public function test(){


        exit;
        $quersion = M('idiom_questions')->field('idiom_questions_id,answer')->select();



        foreach ($quersion as $key=>$vtem){

            $strlen = 18 - mb_strlen($vtem['answer']);

           $str = $vtem['answer'].$this->getChar($strlen);

            $str = $this->str_rev($str);

            $data['puzzle'] = $str;

            M('idiom_questions')->where(array('idiom_questions_id'=>$vtem['idiom_questions_id']))->save($data);

        }


       // print_r($tmp);
    }



    public function test1(){

        return 0;
        exit;
        $quersion = M('idiom_question')->field('images,answer,right_answer,analysis')->select();

        $i = 0;
        foreach ($quersion as $value){
            $i++;
            $data = array(
                'puzzle'=>$value['answer'],
                'answer'=>$value['right_answer'],
                'imgsrc'=>$value['images'],
                'analysis'=>$value['analysis'],
                'sort'=>$i,
                'createtime'=>time(),
            );

            M('idiom_questions')->data($data)->add();
        }

    }


    public function test2(){

        return 1;
        $where['idiom_questions_id'] = array('GT',2580);

        $quertion = M('idiom_questions')->where($where)->select();

        foreach ($quertion as $value){

            $puzzle = $value['puzzle'].$value['answer'];

            $strlen = 24 - mb_strlen($puzzle);

            $str = $puzzle.$this->getChar($strlen);

            $str = $this->str_rev($str);

            $imgsrc = '57/IdiomsQuestionCopy/'.$value['imgsrc'];


            $data = array(
                'puzzle'=>$str,
                'imgsrc'=>$imgsrc,
                'sort'=>$value['idiom_questions_id'],
                'createtime'=>time(),
            );

            M('idiom_questions')->where(array('idiom_questions_id'=>$value['idiom_questions_id']))->save($data);

        }



    }

    public function test5(){
        exit;
        $questions = M('idiom_questions')->select();

        foreach ($questions as $key=>$val){

            M('idiom_questions')->where(array('idiom_questions_id'=>$val['idiom_questions_id']))->save(array('sort'=>$key+1));
        }

    }

    //随机上下
    public function test6(){

        exit;
        $question = M('idiom_questions')->select();

        $suiji = $this->shuffle_assoc($question);
        $suiji = $this->shuffle_assoc($suiji);
        $suiji = array_merge($suiji);

        $data1= array();
        $i=0;

        foreach ($suiji as $key=>$val){

            $i++;

            shuffle($data1);

            $data = array(
                'answer'=>$val['answer'],
                'imgsrc'=>$val['imgsrc'],
                'analysis1'=>$val['analysis1'],
                'sort'=>$i,
                'puzzle'=>$val['puzzle'],
                'analysis'=>$val['analysis'],
            );
            M('idiom_questions2')->data($data)->add();
            echo 0;

        }


    }

}
